package com.cjt.controller;


import com.cjt.common.dto.UserListCollegeSub;
import com.cjt.common.dto.UserListCollegeInfo;
import com.cjt.common.lang.R;
import com.cjt.common.vo.UserEditSubjectVO;
import com.cjt.common.vo.UserListTeacher;
import com.cjt.pojo.Subjet;
import com.cjt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;


    @GetMapping("/listCollege")
    public R listCollege() {
        List<UserListCollegeInfo> list = userService.listCollege();
        return R.success(list);
    }


    @GetMapping("/listsub/{id}")
    public R listSub(@PathVariable Long id) {
        List<UserListCollegeSub> listSub = userService.getListSub(id);
        return R.success(listSub);
    }

    @GetMapping("/gettea/{id}")
    public R listtea(@PathVariable Long id) {
        List<UserListTeacher> listTeachers = userService.listTea(id);
        return R.success(listTeachers);
    }

    @PostMapping("/savesub")
    public R saveSub(@RequestBody UserEditSubjectVO userEditSubjectVO) {
        userService.saveSUb(userEditSubjectVO);
        return R.success(null);
    }

    @PostMapping("/editSub")
    public R editSub(@RequestBody Subjet subjet) {
        userService.editSUb(subjet);
        return R.success(null);
    }

    @PostMapping("/delSub")
    public R delSub(@RequestBody UserEditSubjectVO userEditSubjectVO) {
        userService.delSub(userEditSubjectVO);
        return R.success(null);
    }


}
